﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;


namespace yfxt
{
    public partial class cx_bqfy_crpt : Form
    {
        public cx_bqfy_crpt()
        {
            InitializeComponent();
        }

        zy_fy_DataSet ds = new zy_fy_DataSet();
        static string SQL = "data source=localhost;database=yf;uid=sa;pwd=123;timeout=60";
        private void cs_bqfy_crpt_Load(object sender, EventArgs e)
        {
            string sql_fycx;

            try 
            {
                sql_fycx = "select b.zyh,b.brxm,b.brch,c.ypmc,a.yfgg,a.yfdw,a.fysl,a.ypdj,e.cdmc,a.fygh,a.fyrq,g.fsmc,h.ksmc " +
                "from bq_tj02 a," +
                "zy_brry b," +
                "yk_typk c," +
                "yk_ypcd d," +
                "yk_cddz e," +
                "bq_tj01 f," +
                "zy_fyfs g," +
                "gy_ksdm h " +
                "where a.fybz=1 " +
                "and a.yfbz='" + mainform.yfsb + "' " +
                "and f.fyfs='" + cx_bqfy.fyfs + "' " +
                "and f.tjbq='" + cx_bqfy.ksdm + "' " +
                "and a.tjxh=f.tjxh " +
                "and a.zyh=b.zyh " +
                "and a.ypxh=c.ypxh " +
                "and a.ypxh=d.ypxh " +
                "and d.ypcd=e.ypcd " +
                "and a.fyrq>='" + cx_bqfy.fyrq1 + "' " +
                "and a.fyrq<='" + cx_bqfy.fyrq2 + "' " +
                "and f.fyfs=g.fyfs " +
                "and f.tjbq=h.ksdm " +
                "order by b.zyh";
                SqlConnection con = new SqlConnection(SQL);
                SqlDataAdapter da = new SqlDataAdapter(sql_fycx, con);
                da.Fill(ds.Tables["dt_bqfy"]);
                cx_bqfy_rpt rpt = new cx_bqfy_rpt();
                rpt.SetDataSource(ds);
                crystalReportViewer1.ReportSource = rpt;
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

        }
    }
}
